package Domain;

import java.text.SimpleDateFormat;
import java.util.Date;

import Main.Constants;

/**
 * Holds data about books. Each {@link domain.Book} object contain an internal
 * identifier, **********
 * 
 * @author Daniel Fagerberg
 * 
 */
public class Book extends Entity{
	private String Title;
	private String author;
	private String isbn;
	private String edition;
	private String condition;
	private String subject;
	private double price;
	private Date DateCreated = new Date();
	private int isSold;
	private Seller seller;

	public Book() {
	}
	
	public Book(String title, String isbn, String author, String edition,
			String condition, String subject, java.util.Date DateCreated, int isSold, double price,
			Seller seller) {
		super(-1);
		this.Title = title;
		this.author = author;
		this.isbn = isbn;
		this.edition = edition;
		this.condition = condition;
		this.subject = subject;
		this.DateCreated = DateCreated;
		this.isSold = isSold;
		this.price = price;
		this.seller = seller;
	}
	
	public Book(int id, String title, String isbn, String author, String edition,
			String condition, String subject, java.util.Date DateCreated, int isSold, double price,
			Seller seller) {
		super(id);
		this.Title = title;
		this.author = author;
		this.isbn = isbn;
		this.edition = edition;
		this.condition = condition;
		this.subject = subject;
		this.DateCreated = DateCreated;
		this.isSold = isSold;
		this.price = price;
		this.seller = seller;
	}
	
	@Override
	public String toString() {
		return "[Book: (" + getId() + ") " + Title + ", " + isbn + ", "
		+ author + ", "+ edition + ", "+ condition + ", "+ subject+ ", "+ createSqlDateFormat(DateCreated) + ", "+ isSold + ", "+ ", " + seller + "]";
	}
	
	private String createSqlDateFormat(Date dateCreated) {
		SimpleDateFormat formatter = new SimpleDateFormat(
				Constants.SQL_DATE_FORMAT);
		return formatter.format(dateCreated);
	}

	public String getTitle() {
		return Title;
	}

	public void setTitle(String title) {
		Title = title;
	}
	
	public java.util.Date getDateCreated(){
		return DateCreated;
	}
	
	public Object setDateCreated(java.util.Date DateCreated){
		return this.DateCreated;
	}

	public String getIsbn() {
		return isbn;
	}

	public void setIsbn(String string) {
		this.isbn = string;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getEdition() {
		return edition;
	}

	public void setEdition(String edition) {
		this.edition = edition;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public void setIsSold(int isSold) {
		this.isSold = isSold;
	}

	public int getIsSold() {
		return isSold;
	}

	public void setSeller(Seller seller) {
		this.seller = seller;
	}

	public Seller getSeller() {
		return seller;
	}
}
